const joi = require('joi');
const Schema = {
    username: joi.string().required().min(2).max(5).error(new Error('username属性错误'))
}
async function run() {
    try {
        await joi.validate({ username: 'a' }, Schema)
    } catch (ex) {
        console.log(ex.message)
        return;
    }
    console.log('验证通过')
}
run()